package net.yambal.air.LeafletMap.OverLays
{
	import net.yambal.air.LeafletMap.ILeafletObject;
	import net.yambal.air.LeafletMap.ILeafletOverlay;
	import net.yambal.air.LeafletMap.LatLngBounds;
	import net.yambal.air.LeafletMap.LeafletCoreSinglton;

	public class TileLayer implements ILeafletObject{
		
		private var _label:String;
		private var _UrlTemplate:String;
		private var _replace:Object = null;
		private var _minZoom:int = 0;
		private var _maxZoom:int = 18;
		private var _tileSize:Number = 256;
		private var _subdomains:String = 'abc';
		private var _errorTileUrl:String = '';
		private var _attribution:String = '';
		private var _zoomOffset:int = 0;
		private var _opacity:Number = 1;
        private var _maxBounds:LatLngBounds = null;
		
		private var _leafTyileLayer:Object;
											
		public function TileLayer(
				label:String,
				UrlTemplate:String,
				replace:Object = null,
				minZoom:int = 0,
				maxZoom:int = 18,
				tileSize:Number = 256,
				subdomains:String = 'abc',
				errorTileUrl:String = '',
				attribution:String = '',
				zoomOffset:int = 0,
				opacity:Number = 1,
                maxBounds:LatLngBounds = null){
			
			this._label = label;
			this._UrlTemplate = UrlTemplate;
			this._replace = replace;
			this._minZoom = minZoom;
			this._maxZoom = maxZoom;
			this._tileSize = tileSize;
			this._subdomains = subdomains;
			this._errorTileUrl = errorTileUrl;
			this._attribution = attribution;
			this._zoomOffset = zoomOffset;
			this._opacity = opacity;
            this._maxBounds = maxBounds;
			
			var res:Object = this._replace;
			if(res == null){
				res = new Object();
			}
			
			res.minZoom = this._minZoom;
			res.maxZoom = this._maxZoom;
			res.tileSize = this._tileSize;
			res.subdomains = this._subdomains;
			res.errorTileUrl = this._errorTileUrl;
			res.attribution = this._attribution;
			res.zoomOffset = this._zoomOffset;
			res.opacity = this._opacity;
			
			this._leafTyileLayer = LeafletCoreSinglton.instance.tileLayer(this._UrlTemplate, res);
			
		}
		
		public function get minZoom():int{
			return this._minZoom;
		}
		
		public function get maxZoom():int{
			return this._maxZoom;
		}
		
		public function get label():String{
			return this._label;
		}
		
		/*
		public function get leafTyileLayer():Object{
			return this._leafTyileLayer;
		}
		*/
		
		public function get LeafObject():Object{
			return this._leafTyileLayer;
		}

        public function get maxBounds():LatLngBounds{
            return this._maxBounds;
        }

        /*
        public function get LeafMaxBounds():Object{
            return this._maxBounds.LeafObject;
        }
		*/
	}
}